package com.tengju.data.domain.model.clickhouse.star;

import com.tengju.data.domain.model.user.StarLevelEnum;
import lombok.Value;

import java.util.List;


@Value
public class DominationMemberNew {

    Integer newEcNum;

    Integer newCityStarOneNum;

    Integer newCityStarTwoNum;

    Integer newCityStarThreeNum;

    Integer newCityStarFourNum;

    Integer newDealerNum;

    public boolean hasNewMember() {
        return (newEcNum != null && newEcNum > 0) ||
                (newCityStarOneNum != null && newCityStarOneNum > 0) ||
                (newCityStarTwoNum != null && newCityStarTwoNum > 0) ||
                (newCityStarThreeNum != null && newCityStarThreeNum > 0) ||
                (newCityStarFourNum != null && newCityStarFourNum > 0) ||
                (newDealerNum != null && newDealerNum > 0);
    }

    public boolean hasNewEcMember() {
        return newEcNum != null && newEcNum > 0;
    }

    public boolean hasNewCityStarMember() {
        return (newCityStarOneNum != null && newCityStarOneNum > 0) ||
                (newCityStarTwoNum != null && newCityStarTwoNum > 0) ||
                (newCityStarThreeNum != null && newCityStarThreeNum > 0) ||
                (newCityStarFourNum != null && newCityStarFourNum > 0);
    }

    public boolean hasNewDealerMember() {
        return newDealerNum != null && newDealerNum > 0;
    }


    public Integer getTotal(List<StarLevelEnum> starLevels) {

        Integer total = 0;
        for (StarLevelEnum starLevel : starLevels) {
            Integer num = getByStarLevel(starLevel);
            total = total + num;
        }

        return total;

    }


    public Integer getByStarLevel(StarLevelEnum starLevel) {

        switch (starLevel) {
            case NONE:
                return newDealerNum;
            case EC:
                return newEcNum;
            case CITY_STAR_ONE:
                return newCityStarOneNum;
            case CITY_STAR_TWO:
                return newCityStarTwoNum;
            case CITY_STAR_THREE:
                return newCityStarThreeNum;
            case CITY_STAR_FOUR:
                return newCityStarFourNum;
            default:
                return 0;
        }
    }
}
